package com.cskaoyan.servlet;

import com.cskaoyan.bean.MarketFootprint;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.FootService;
import com.cskaoyan.service.FootServiceImpl;
import com.cskaoyan.util.ResponseUtil;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/admin/footprint/*")
public class AdminFootServlet extends WdBaseServlet {

    FootService footService = new FootServiceImpl();

    public void list(HttpServletRequest request, HttpServletResponse response) throws IOException {
        Integer page = Integer.parseInt(request.getParameter("page"));
        Integer limit = Integer.parseInt(request.getParameter("limit"));
        String order = request.getParameter("order");
        String sort = request.getParameter("sort");

        Integer userId=null;
        if (request.getParameter("userId")==null||request.getParameter("userId").equals("")){
            userId=null;
        }else {
            userId=Integer.parseInt(request.getParameter("userId"));
        }

        Integer goodsId=null;
        if (request.getParameter("goodsId")==null||request.getParameter("goodsId").equals("")){
            goodsId=null;
        }else {
            goodsId=Integer.parseInt(request.getParameter("goodsId"));
        }


        CommonData<MarketFootprint> data = footService.query(page,limit,sort,order,userId,goodsId);
        ResponseUtil.responseJson(response, BaseRespVo.ok(data));
    }

}
